//package com.ruibang.glass.produce.component.job;
//
//
//import com.ruibang.glass.produce.constant.Constants;
//import com.teaming.cloud.framework2.autoconfigure.dynamic.datasource.DynamicRoutingDataSource;
//
//import com.teaming.cloud.framework2.elastic.job3.annotation.ElasticJobScheduler;
//import com.zaxxer.hikari.HikariConfig;
//import com.zaxxer.hikari.HikariDataSource;
//import lombok.extern.slf4j.Slf4j;
//
//import org.apache.shardingsphere.elasticjob.api.ShardingContext;
//import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
//import org.springframework.context.annotation.Bean;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.time.LocalDate;
//import java.time.format.DateTimeFormatter;
//
///**
// * @Author: songJinKang
// * @CreateTime: 2023-12-01  09:55
// * @Description: TODO：冷端天库数据源刷新
// * @Version: 1.0
// */
//
//@Slf4j
//@ElasticJobScheduler(cron = "0 55 0 * * ? ")
////@ElasticJobScheduler(cron = "0 * * * * ?")
//@Component
//public class DataBaseJob implements SimpleJob {
//
//    @Resource
//    private DynamicRoutingDataSource dataSource;
//
//    @Override
//    public void execute(ShardingContext shardingContext) {
//        dataSource.removeDataSource(Constants.COLD_DATA_SOURCE_NAME);
//        createConn();
//    }
//
//    @Bean
//    public void dayDataBase() {
//        createConn();
//    }
//
//    private void createConn() {
//        try {
//            HikariConfig hikariConfig = new HikariConfig();
//            String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
//            hikariConfig.setDriverClassName("com.mysql.jdbc.Driver");
//            hikariConfig.setJdbcUrl("jdbc:mysql://172.19.100.10:3306/fpm_db_" + date + "_0000_cold1?useUnicode=true&characterEncoding=utf8&useSSL=false&connectTimeout=30000&socketTimeout=60000");
//            hikariConfig.setUsername("root");
//            hikariConfig.setPassword("sh@2021");
//            hikariConfig.setPoolName(Constants.COLD_DATA_SOURCE_NAME);
//            hikariConfig.validate();
//            dataSource.addDataSource(Constants.COLD_DATA_SOURCE_NAME, new HikariDataSource(hikariConfig));
//        } catch (Exception e) {
//            log.error("创建天数据源失败：{}", e.getMessage());
//        }
//    }
//}
